<!DOCTYPE html>

<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			
		
			
		</style>
		
		<script>
			let timeid = null;
			function displayDiv(){
				timeid = setTimeout(function(){
					document.getElementById("d1").style.display = "none";

				},3000)
			}
			
			function clearTime(){
				if(timeid){
					clearTimeout(timeid)
				}
				
			}
				
				
			
			
		</script>
	
		
	</head>
	<body>
	<button onclick="clearTime()">取消延时函数</button>


	 <div id="d1" onclick="displayDiv()" style="width: 300px;height: 300px;border: solid 1px red;">

		
	</div>
	content

	
	</body>
</html>